<template>
  <el-container>
    <el-header height="88px">
      <el-row :gutter="10">
        <el-col :xs="8" :sm="6" :md="4" :lg="4" :xl="3">
          <div class="logoBox">
            <img src="../../assets/images/logo.png" alt="" />
          </div>
        </el-col>
        <el-col :xs="8" :sm="12" :md="16" :lg="16" :xl="18" class="middle">
          <div class="grid-content bg-purple-light search">
            <div class="search-img">
              <img src="../../assets/images/fangdajing.png" alt="" />
            </div>
            <el-input
              v-model="input"
              placeholder="&nbsp;&nbsp;&nbsp;&nbsp;搜索"
              clearable
            >
            </el-input>
          </div>
          <div class="empty">&nbsp;&nbsp;</div>
        </el-col>
        <el-col :xs="8" :sm="6" :md="4" :lg="4" :xl="3">
          <div class="grid-content bg-purple-light right">
            <span>{{ timer }}</span>
            <img src="../../assets/images/8.png" alt="" />
          </div>
        </el-col>
      </el-row>
    </el-header>
    <el-container>
      <el-aside width="322px">
        <el-row>
          <el-col :span="24">
            <el-menu :default-active="urlSite" router @select="handleSelect">
              <el-menu-item index="/index/content" class="button">
                <div class="option">
                  <img src="../../assets/images/1.png" alt="" />
                  <div class="wordage">首页</div>
                </div>
              </el-menu-item>
              <el-menu-item index="/index/manage" class="button">
                <div class="option">
                  <img src="../../assets/images/2.png" alt="" />
                  <div>产品管理</div>
                </div>
              </el-menu-item>
              <el-menu-item index="/index/distribute" class="button">
                <div class="option">
                  <img src="../../assets/images/3.png" alt="" />
                  <div>店铺分布</div>
                </div>
              </el-menu-item>
              <el-menu-item index="/index/leave" class="button">
                <div class="option">
                  <img src="../../assets/images/4.png" alt="" />
                  <div class="wordage">留言</div>
                </div>
              </el-menu-item>
              <el-menu-item index="/index/admin" class="button">
                <div class="option">
                  <img src="../../assets/images/5.png" alt="" />
                  <div class="wordage">管理员</div>
                </div>
              </el-menu-item>
              <el-menu-item index="/index/account" class="button">
                <div class="option">
                  <img src="../../assets/images/6.png" alt="" />
                  <div>账号设置</div>
                </div>
              </el-menu-item>
              <el-menu-item index="/login" class="quit">
                <div class="option">
                  <img src="../../assets/images/quit.png" alt="" />
                  <div class="wordage">退出</div>
                </div>
              </el-menu-item>
            </el-menu>
          </el-col>
        </el-row>
      </el-aside>
      <router-view></router-view>
    </el-container>
  </el-container>
</template>

<script>
import { ref } from "vue";

export default {
  setup() {
    const input = ref("");

    let timer = time();

    const urlSite = ref("$router.path");

    return {
      input,
      timer,
      urlSite,
    };
  },
};

// 时间
const time = () => {
  let data = new Date();
  let hours = data.getHours(); //小时 ,返回 Date 对象的小时 (0 ~ 23)
  let minutes = data.getMinutes(); //分钟 ,返回 Date 对象的分钟 (0 ~ 59)
  let seconds = data.getSeconds();
  //修改小时格式
  if (hours >= 0 && hours <= 9) {
    hours = "0" + hours;
  }

  //修改分钟格式
  if (minutes >= 0 && minutes <= 9) {
    minutes = "0" + minutes;
  }

  //修改秒格式
  if (seconds >= 0 && seconds <= 9) {
    seconds = "0" + seconds;
  }
  let currentDate = hours + ":" + minutes + ":" + seconds;
  return currentDate;
};
</script>

<style lang="less" scoped>
.el-container {
  height: 100%;
  background: #bbbcba;
}

// 头部
.el-header {
  background-color: #fff;
  text-align: center;
  line-height: 88px;
  margin-bottom: 20px;
  .el-col {
    display: flex;
    justify-content: center;
    align-items: center;
  }
  // 中间
  .middle {
    display: flex;
    justify-content: space-around;
  }
  // 图片
  .logoBox {
    width: 107px;
    height: 48px;
    img {
      width: 100%;
      height: 100%;
    }
  }
  // 搜索
  .search {
    display: flex;
    justify-content: center;
    position: relative;
    transform: translateX(-50px);
    .search-img {
      width: 24px;
      height: 26px;
      position: absolute;
      left: -20px;
      top: 12px;
      z-index: 5;
      img {
        display: block;
        width: 100%;
      }
    }
    /deep/.el-input__inner {
      border: none;
      outline: none;
      width: 486px;
      height: 48px;
      background: url("../../assets/images/7.png");
    }
  }

  // 头部右侧
  .right {
    display: flex;
    align-items: center;
    span {
      font-size: 30px;
      color: #333333;
      margin-right: 18px;
    }
  }
}

// 左侧
.el-aside {
  background-color: #fff;
  text-align: center;
  margin-right: 36px;
  .el-row {
    line-height: 50px;
    .el-col {
      margin-bottom: 42px;
    }
    .option {
      display: flex;
      justify-content: space-between;
      align-items: center;
      width: 130px;
      height: 100%;
      .wordage {
        width: 72px;
      }
    }
    img {
      width: 35px;
      height: 34px;
    }
  }
}
// 按钮
.el-menu {
  text-align: center;
  .button {
    font-size: 18px;
    justify-content: center;
    color: #333333;
    line-height: 31px;
    font-weight: 600;
    margin-bottom: 3vh;
  }
  .quit {
    font-size: 18px;
    color: #333333;
    line-height: 31px;
    font-weight: 600;
    justify-content: center;
    margin-top: 30vh;
  }
}
/deep/.el-menu-item.is-active {
  background: rgb(217, 226, 200);
  color: #333333;
  border-right: 5px solid rgb(107, 148, 127);
  i {
    color: white;
  }
}
</style>
